package springboot.service.impl;

import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;
import springboot.dao.WxUserDao;
import springboot.doMain.WxUser;
import springboot.service.WXUserService;

import java.util.List;

/**
 * wxWork
 * springboot.service.impl
 * Created by Blue on 2021/9/26.
 */
@Repository
@Service
public class WXUserServiceImpl implements WXUserService {
	
	final
	WxUserDao wxUserDao;
	
	public WXUserServiceImpl(WxUserDao wxUserDao) {
		this.wxUserDao = wxUserDao;
	}
	
	@Override
	public int deleteByPrimaryKey(Integer id) {
		return 0;
	}
	
	@Override
	public int insert(WxUser record) {
		WxUser wxUser = wxUserDao.selWxUser(record);
		if (wxUser == null) {
			if (wxUserDao.insert(record) == 1) {
				System.out.println("插入员工成功");
				return 1;
			} else {
				System.out.println("插入员工失败");
				return -1;
			}
		} else {
			if (wxUserDao.updateByUserId(record) == 1) {
				System.out.println("更新员工成功");
				return 2;
			} else {
				System.out.println("更新员工失败");
				return -2;
			}
		}
	}
	
	@Override
	public List<WxUser> selAllWxUser() {
		return wxUserDao.selAllWxUser();
	}
	
	@Override
	public List<WxUser> selAllRemark() {
		return wxUserDao.selAllRemark();
	}
	
	@Override
	public int insertSelective(WxUser record) {
		return 0;
	}
	
	@Override
	public int updateByPrimaryKeySelective(WxUser record) {
		return 0;
	}
	
	@Override
	public int updateByPrimaryKey(WxUser record) {
		return 0;
	}
}
